\section{Black-Scholes PDE}
By Black-Scholes the fair price of an European claim with payoff $f(S_T)$ is given by 
\[
V(T,S_T)=\frac{e^{-rT}}{\sqrt{2\pi}}\int_{\mathbb R}f(S_0e^{(r-\frac{1}{2}\sigma^2)T+\sigma z\sqrt T })e^{\frac{1}{2}z^2}dz,
\]
with $S_0$ the stock price at time $t=0$, $\sigma$ the volatility and $r$ the
risk-free interest rate of the stock. 
This formulae can be extended to a formula for a price at any $t\leq T$. From
the absence of arbitrage it follows that this price equals the value $V_t$ of
the hedging portfolio at time $t$. It holds that $V(t,S_t)$ evolves according
to the following equation
\[
V(t,x)= \frac{e^{-r(T-t)}}{\sqrt{2\pi}}\int_{\mathbb R}f(xe^{(r-\frac{1}{2}\sigma^2)(T-t)+\sigma z\sqrt{T-t} })e^{\frac{1}{2}z^2}dz.
\]
This pricing formula can also be obtained as the solution of the so-called
Black-Scholes partial differential equation (PDE). In this section it is shown
how this is done.
\noindent
To get the wanted Black-Scholes PDE we need to use Ito's Lemma for a function
with two variables. This lemma states that when we have a stochastic
differential equation $S_t$ and a twice continuously differentiable function
$f:[0,\infty)x\mathbb R\rightarrow \mathbb R$ then,
\[
df(t,S_t)=\frac{df}{dt}(t,S_t)dt+\frac{df}{dS_t}(t,S_t)dS_t+\frac{1}{2}\frac{d^2}{dS^t_t}(t,S_t)d[S]_t.
\]
By Ito's lemma we know that the partial differential equation of the value
process satisfies the following equation.
\[
dV(t,S_t)=\frac{dV}{dt}(t,S_t)dt+\frac{dV}{dS_t}(t,S_t)dS_t+\frac{1}{2}\frac{d^2V}{dS^2_t}(t,S_t)d[S]_t
\]
The quadratic variation $d[S]_t$ for a stock price is of the form
$\sigma^2S_t^2dt$, and when $S_t$ follows a geometric Brownian Motion $dS_t=r
S_t dt+\sigma S_tdW_t$, resulting into
\[
dV(t,S_t)=\frac{dV}{dt}(t,S_t)dt +\frac{dV}{dS_t}(t,S_t)r S_tdt+\frac{1}{2}\frac{d^2V}{dS^2_t}(t,S_t)\sigma^2S_t^2dt+\frac{dV}{dS_t}(t,S_t)\sigma S_tdW_t.
\]
If we now set up a portfolio consisting of $-1$ derivative and
$\frac{dV}{dS_t}$ shares the value of the portfolio is given by
$\Pi=-V+\frac{dV}{dS_t}S_t$, the change over time $dt$ is given by $d\Pi=-d
V+\frac{dV}{dS_t}dS_t$.
\noindent
The return on a portfolio should be the risk-free rate, due to the non-arbitrage argument, hence it should
satisfy the equality $d \Pi=r\Pi d t$.
\begin{eqnarray*}
d \Pi&=&r\Pi d t\\
-dV+\frac{dV}{dS_t}dS_t&=&-rVd_t+\frac{dV}{dS_t}rS_tdt\\
rVdt-\frac{dV}{dS_t}rS_tdt&=&\frac{dV}{dt}dt+\frac{dV}{dS_t}rS_tdt+\frac{1}{2}\sigma^2S_t^2\frac{d^2V}{dS^2_t}dt+\sigma S_t\frac{dV}{dS_t}dW_t-\frac{dV}{dS_t}rS_tdt-\frac{dV}{dS_t}\sigma S_tdW_t\\
rVdt&=&\frac{dV}{dt}dt+\frac{dV}{dS_t}rS_tdt+\frac{1}{2}\sigma^2S_t^2\frac{d^2V}{dS^2_t}dt\\
\end{eqnarray*}
Resulting in the Black-Scholes Partial Differential Equation
\begin{equation}\label{eq:BSPDE}
rV=\frac{dV}{dt}+\frac{dV}{dS_t}rS_t+\frac{1}{2}\sigma^2S_t^2\frac{d^2V}{dS^2_t}.
\end{equation}
This partial differential equation is subject to the boundary condition
$V(T,S_T)=f(S_T)$ with $f(S_T)$ the payoff of the option at expiry.\\

\section{Finite Difference Background}
This equation can be transformed into a PDE with constant coefficients by
introducing $X=\ln S$. With this transformation we get the following
equations 
\begin{align}
\frac{dV}{dS_t}&=\frac{dV}{dX}\frac{dX}{dS_t}=\frac{1}{S_t}\frac{dV}{dX}\\
\frac{d^2V}{dS_t^2}&=\frac{d}{dS_t}\left(\frac{1}{S_t}\frac{dV}{dX}\right)=-\frac{1}{S_t^2}\frac{dV}{dX}+\frac{1}{S_t^2}\frac{d^2V}{dX^2}.
\end{align}
Since the equation is commonly solved backward in time ($\tau=T-t$), it is for
further numerical treatment convenient to introduce the following
transformation
\[
\frac{dV}{dt}=-\frac{dV}{d\tau}.
\]
Inserting these equations into the Black-Scholes PDE leads to the following transformed Black-Scholes PDE
\[
\frac{dV}{d\tau}=(r-\frac{1}{2}\sigma^2)\frac{dV}{dX}+\frac{1}{2}\sigma^2\frac{d^2V}{dX^2}-rV.
\]
This equation can be solved numerically by discrete variant obtained by using the Taylor Expansion Technique:
\begin{multline}
V(X+\Delta X,\tau + \Delta \tau)=V(X,\tau)+\Delta X\frac{dV(X,\tau)}{dX}+\Delta \tau\frac{dV(X,\tau)}{d\tau}+\\
\frac{1}{2}\Delta X^2\frac{d^2V(X,\tau)}{dX^2}+\frac{1}{2}\Delta \tau^2\frac{d^2V(X,\tau)}{d\tau^2}+ \Delta \tau\Delta X \frac{d^2 V(X, \tau)}{d\tau dX}+\ldots.
\end{multline}
In order to go to finite difference we divide the interval $[0,T]$ and the
interval $[0, S_T]$ both into $N$ equally sized subintervals. This results in
\begin{eqnarray*}
\frac{dV}{d\tau}(x\Delta X,\tau\Delta\tau)&=&\frac{V_x^{\tau +1}-V_x^\tau}{\Delta \tau}+O(\Delta \tau)\\
\frac{dV}{dX}(x\Delta X,\tau\Delta\tau)&=&\frac{V_{x+1}^{\tau }-V_{x-1}^\tau}{2\Delta X}+O(\Delta x^2)\\
\frac{d^2V}{dX^2}(x\Delta X,\tau\Delta\tau)&=&\frac{V_{x+1}^{\tau }-2V_x^\tau+V_{x-1}^\tau}{\Delta X^2}+O(\Delta x^2).
\end{eqnarray*}
Together with the Taylor Expansion this results in the following equation

\begin{equation}\label{eq:ForwardTime}
\frac{V_x^{\tau +1}-V_x^\tau}{\Delta \tau}= (r-\frac{1}{2}\sigma^2)\frac{V_{x+1}^{\tau }-V_{x-1}^\tau}{2\Delta X}+\frac{1}{2}\sigma^2\frac{V_{x+1}^{\tau }-2V_x^\tau+V_{x-1}^\tau}{\Delta X^2}-rV_x^\tau
\end{equation}
This is the explicit Forward Time Centered Scheme (FCTS), this scheme is first order is time and of second order in space.
\noindent
This equation can be made implicit in time resulting in the Backward Time
Centered Scheme (BTCS):
\[
\frac{V_x^{\tau +1}-V_x^\tau}{\Delta\tau}= (r-\frac{1}{2}\sigma^2)\frac{V_{x+1}^{\tau +1}-V_{x-1}^{\tau +1}}{2\Delta X}+\frac{1}{2}\sigma^2\frac{V_{x+1}^{\tau +1}-2V_x^{\tau +1}+V_{x-1}^{\tau +1}}{\Delta X^2}-rV_x^{\tau +1}
\]
A way of obtaining $2^{\tau d}$-order accuracy in time is by construction an
averaged scheme from FTCS and BTCS
\begin{multline}\label{eq:CrankNicolson}
\frac{V_x^{\tau +1}-V_x^\tau}{\Delta \tau}=
(r-\frac{1}{2}\sigma^2)\frac{V_{x+1}^{\tau +1}-V_{x-1}^{\tau +1}+V_{x+1}^\tau-V_{x-1}^\tau}{4\Delta X}+\\
\frac{1}{2}\sigma^2\frac{V_{x+1}^{\tau +1}-2V_x^{\tau +1}+V_{x-1}^{\tau +1}+V_{x+1}^{\tau }-2V_x^\tau-V_{x-1}^\tau}{2\Delta X^2}-\frac{r}{2}(V_x^{\tau +1}+V_x^{\tau})
\end{multline}
this is the so called Crank-Nicolson Scheme. The order of the error of the
Crank-Nicolson scheme is $O(\Delta\tau^2)+O(\Delta x^2)$.
\noindent
So both the FCTS and the CNS can be solved on a grid of $[0,T]$ and $[0,
S_t]$, each divided into $N$ equally sized intervals. Before we can use these
equations to calculate the premium of an option we need to rewrite them in such
a way that they can easily be solved.

